package com.demo3;

import java.util.Scanner;

/**
 * 长方形
 * @author J.L.Zhou
 *	jlzhou.top 版权所有
 */
public class Rectangle extends AbstractShape {
	/**
	 * 宽
	 */
	private float width;
	/**
	 * 高
	 */
	private float height;


	public Rectangle(){
		super("长方形");
	}

	protected Rectangle(String name){
		super(name);
	}


	@Override
	public void inputBaseInfo(Scanner sc) {
		System.out.println("输入"+getName()+"的宽度: ");
		width = sc.nextFloat();

		System.out.println("输入"+getName()+"的高度: ");
		height = sc.nextFloat();
	}

	@Override
	public float calcArea() {
		return width*height;
	}

	@Override
	public float caclPerimeter() {
		return (width+height) *2;
	}



	@Override
	public String getBaseInfo() {
		return String.format("宽度：%.2f\t高度：%.2f",width,height);
	}


	public float getWidth() {
		return width;
	}

	public void setWidth(float width) {
		this.width = width;
	}

	public float getHeight() {
		return height;
	}

	public void setHeight(float height) {
		this.height = height;
	}
	
	public static void main(String[] args) {
		Rectangle rectangle = new Rectangle();
		rectangle.input(new Scanner(System.in));
		rectangle.show();
	}

}
